import { Component, OnInit } from '@angular/core';
import { MessageService } from '../../../../core/service';
import { ApiService, urlService } from 'src/app/core/api';
import { FormBuilder, Validators, FormGroup } from '@angular/forms';
import { NzModalService } from 'ng-zorro-antd';
import { MemberService } from 'src/app/routes/member-center/member.server';

@Component({
  selector: 'my-account',
  templateUrl: './my-account.component.html',
  styleUrls: ['./my-account.scss']
})
export class MyAccountComponent implements OnInit {

  url = 'account';
  validateForm: FormGroup;
  private _user:any={};
  imgUrl:string ='../../../../assets/img/tx.jpg';

  ngOnInit() {
    this.msg.sendMessage(this.url);
    this.loaPage('个人中心[Web前端专用]')
  };

  async loaPage(url) {
    let data = await this.memberServer.getAJX(url,{});
    this.memberServer.getApiSuccess(data,false) ? this.successListOk(data.data, url) : '';
  };

  public successListOk(data,url):void{
    switch (url) {
      case '个人中心[Web前端专用]':
        data.image ? this.imgUrl = data.image : data.image = '../../../../assets/img/tx.jpg';
        this._user = data;
        console.log(this._user)
      break;
    };
  };

  constructor(
    private memberServer: MemberService,
    private fb: FormBuilder,
    private msg:MessageService
  
  ) { 
    this.validateForm = this.fb.group({
      verifyCode: [ '', [ Validators.required ] ],
      newConfirmPwd: [ '', [ Validators.required ] ],
      newPwd   : [ '', [ Validators.required ] ],
      oldPwd: [ '', [ Validators.required ] ],
    });
  };
};

